package cn.tedu.shoot;

import java.awt.image.BufferedImage;
import java.util.Random;

/*小蜜蜂*/
public class Bee extends FlyingObject implements EnemyAward {
    private int index = 1;
    private int xSpeed;
    private int ySpeed;
    private int awardType;//奖励类型

    Bee() {
        super(60, 51);
        Random random = new Random();
        int a = random.nextInt(2);
        if (a == 0) {
            xSpeed = 2;
        } else {
            xSpeed = -2;
        }

        ySpeed = 4;

        awardType = random.nextInt(2);
    }

    public void step() {
        x += xSpeed;
        y += ySpeed;
        if (x >= World.WIDTH - width || x <= 0) {
            xSpeed = -xSpeed;
        }
    }

    public BufferedImage getImage() {
        if (isLive()) {
            return Images.bees[0];
        } else if (isDead()) {
            BufferedImage img = Images.bees[index++];
            if (index == Images.bees.length) {
                stated = REMOVE;
            }
            return img;
        } else {
            return null;
        }
    }

    public int  getAwardType(){
        return awardType;
    }
}
